#include <iostream>
#include <thread>
#include <functional>
using namespace std;

function<void(int)> f = [](int x)
{
  cout << "Child id = " << this_thread::get_id() << endl;
  cout << "function<void(int)> f()" << endl;
  cout << "x = " << x << endl;
};

int main()
{
  cout << "Main id = " << this_thread::get_id() << endl;

  thread th(f, 6); // 线程入口函数可以传递function对象

  cout << "Child id = " << th.get_id() << endl;
  th.join(); // 主线程等待子线程执行结束
  return 0;
}